package com.xing.binbackend.pattern.factory12.ecommerce;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

// 3. 使用BeanFactory获取实例
@Service
public class PaymentService {
    @Autowired
    private BeanFactory beanFactory;

    public void handlePayment(String type, double amount) {
        Payment processor = beanFactory.getBean(type, Payment.class);
        processor.pay(amount);
    }
}
